package com.bjsxt.shop.back.controller;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bjsxt.shop.common.controller.BaseController;
import com.bjsxt.shop.common.util.ConstatFinalUtil;
import com.bjsxt.shop.common.util.PageInfoUtil;
import com.bjsxt.shop.goods.pojo.AGoods;
import com.bjsxt.shop.goods.pojo.AGoodsBrand;
import com.bjsxt.shop.goods.pojo.AGoodsBrandEnum;
import com.bjsxt.shop.goods.pojo.AGoodsCate;
import com.bjsxt.shop.goods.pojo.AGoodsCateEnum;
import com.bjsxt.shop.goods.service.IGoodsService;
import com.bjsxt.shop.users.pojo.AAdmins;

/**
 * 商品的Controller
 * 
 * @author wangshSxt
 *
 */
@Controller
@RequestMapping("/back/goods")
public class GoodsBackController extends BaseController
{
	@Resource
	private IGoodsService goodsService;
	/*----------品牌操作开始---------*/
	/**
	 * 品牌列表
	 * 
	 * @return
	 */
	@RequestMapping("/brandList")
	public String brandList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- brandList ----");
		/* 接收搜索条件 */
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		/* 处理搜索条件 */
		if(keyword == null)
		{
			keyword = ""; 
		}
		keyword = keyword.trim() ; 
		if(status == null)
		{
			status = ""; 
		}
		if(st == null)
		{
			st = ""; 
		}
		if(ed == null)
		{
			ed = ""; 
		}
		
		Date stDate = null ; 
		Date edDate = null ; 
		if(!"".equalsIgnoreCase(st) && !"".equalsIgnoreCase(ed))
		{
			stDate = this.dateFormatUtil.parse(st);
			edDate = this.dateFormatUtil.parse(ed);
		}
		
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		if(!"".equalsIgnoreCase(status))
		{
			condMap.put("status", status);
		}
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		/* 分页 */
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		List<AGoodsBrand> goodsBrandList = this.goodsService.findCondListGoodsBrandService(pageInfoUtil, condMap);
		
		/* 存储结果 */
		request.setAttribute("goodsBrandList", goodsBrandList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		request.setAttribute("websitePath", ConstatFinalUtil.BUNDLE.getString("website.path"));
		
		/* 存储条件 */
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		return "/back/goods/brandList";
	}
	
	/**
	 * 品牌添加
	 * @return
	 */
	@RequestMapping("/brandInsert")
	public String brandInsert()
	{
		ConstatFinalUtil.LOGGER.info("---- brandInsert ----");
		return "/back/goods/brandInsert";
	}
	
	/**
	 * 品牌添加提交
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/brandInsertSubmit")
	public String brandInsertSubmit(HttpServletRequest request,AGoodsBrand goodsBrand,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- brandInsertSubmit ----");
		HttpSession session = request.getSession() ; 
		AAdmins admins = (AAdmins) session.getAttribute("admins");
		
		String pubTimeStr = request.getParameter("pubTimeStr");
		goodsBrand.setPubTime(this.dateFormatUtil.parse(pubTimeStr));
		
		goodsBrand.setAdminsId(admins.getId());
		goodsBrand.setCreateTime(new Date());
		goodsBrand.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		if(file != null)
		{
			paramsMap.put("oriFileName", file.getOriginalFilename());
			paramsMap.put("inputStream", file.getInputStream());
		}
		JSONObject resDBJSON = this.goodsService.saveOneGoodsBrandService(goodsBrand,paramsMap);
		this.info = resDBJSON.getString("info");
		request.setAttribute("info", info);
		return this.brandInsert();
	}
	/**
	 * 品牌更新
	 * @return
	 */
	@RequestMapping("/brandUpdate")
	public String brandUpdate(HttpServletRequest request , String bid)
	{
		ConstatFinalUtil.LOGGER.info("---- brandUpdate ----");
		/* 按照Id查询 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", bid);
		/* 查询数据库 */
		AGoodsBrand goodsBrand = this.goodsService.findOneGoodsBrandService(condMap);
		/* 存储request */
		request.setAttribute("goodsBrand", goodsBrand);
		request.setAttribute("websitePath", ConstatFinalUtil.BUNDLE.getString("website.path"));
		return "/back/goods/brandUpdate";
	}
	
	/**
	 * 品牌更新提交
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/brandUpdateSubmit")
	public String brandUpdateSubmit(HttpServletRequest request,String bid ,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- brandUpdateSubmit ----");
		/* 按照Id查询 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", bid);
		/* 查询数据库 */
		AGoodsBrand goodsBrand = this.goodsService.findOneGoodsBrandService(condMap);
		/* 存储request */
		request.setAttribute("goodsBrand", goodsBrand);
		
		String pubTimeStr = request.getParameter("pubTimeStr");
		goodsBrand.setPubTime(this.dateFormatUtil.parse(pubTimeStr));
		
		String name = request.getParameter("name");
		String website = request.getParameter("website");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		
		goodsBrand.setName(name);
		goodsBrand.setWebsite(website);
		goodsBrand.setContent(content);
		goodsBrand.setStatus(Byte.valueOf(status));
		
		goodsBrand.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		if(file != null)
		{
			paramsMap.put("oriFileName", file.getOriginalFilename());
			paramsMap.put("inputStream", file.getInputStream());
		}
		JSONObject resDBJSON = this.goodsService.updateOneGoodsBrandService(goodsBrand,paramsMap);
		this.info = resDBJSON.getString("info");
		request.setAttribute("info", info);
		return this.brandUpdate(request,bid);
	}
	/*----------品牌操作结束---------*/
	
	/*----------分类操作开始---------*/
	/**
	 * 分类列表
	 * @return
	 */
	@RequestMapping("/cateList")
	public String cateList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- cateList ----");
		/* 接收搜索条件 */
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		/* 处理搜索条件 */
		if(keyword == null)
		{
			keyword = ""; 
		}
		keyword = keyword.trim() ; 
		if(status == null)
		{
			status = ""; 
		}
		if(st == null)
		{
			st = ""; 
		}
		if(ed == null)
		{
			ed = ""; 
		}
		
		Date stDate = null ; 
		Date edDate = null ; 
		if(!"".equalsIgnoreCase(st) && !"".equalsIgnoreCase(ed))
		{
			stDate = this.dateFormatUtil.parse(st);
			edDate = this.dateFormatUtil.parse(ed);
		}
		
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		if(!"".equalsIgnoreCase(status))
		{
			condMap.put("status", status);
		}
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		/* 分页 */
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		List<AGoodsCate> cateList = this.goodsService.findCondListGoodsCateService(pageInfoUtil, condMap);
		
		/* 存储结果 */
		request.setAttribute("cateList", cateList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		
		/* 存储条件 */
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		return "/back/goods/cateList" ; 
	}
	/**
	 * 分类列表
	 * @return
	 */
	@RequestMapping("/cateTreeList")
	public String cateTreeList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- cateTreeList ----");
		Map<String, Object> condMap = new HashMap<String, Object>(); 
		condMap.put("parentId", "0");
		List<AGoodsCate> goodsCateList = this.goodsService.findCondListGoodsCateService(null, condMap);
		JSONArray goodsCateTreeArr = this.goodsService.findTreeGoodsCateService(goodsCateList,request.getContextPath());
		request.setAttribute("goodsCateTreeArr", goodsCateTreeArr);
		return "/back/goods/cateTreeList" ; 
	}
	/**
	 * 分类添加
	 * @return
	 */
	@RequestMapping("/cateInsert")
	public String cateInsert()
	{
		ConstatFinalUtil.LOGGER.info("---- cateInsert ----");
		return "/back/goods/cateInsert";
	}
	
	/**
	 * 分类添加提交
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/cateInsertSubmit")
	public String cateInsertSubmit(HttpServletRequest request,AGoodsCate goodsCate,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- cateInsertSubmit ----");
		HttpSession session = request.getSession() ; 
		AAdmins admins = (AAdmins) session.getAttribute("admins");
		
		String pubTimeStr = request.getParameter("pubTimeStr");
		goodsCate.setPubTime(this.dateFormatUtil.parse(pubTimeStr));
		
		goodsCate.setAdminsId(admins.getId());
		goodsCate.setCreateTime(new Date());
		goodsCate.setUpdateTime(new Date());
		
		JSONObject resDBJSON = this.goodsService.saveOneGoodsCateService(goodsCate);
		this.info = resDBJSON.getString("info");
		request.setAttribute("info", info);
		return this.cateInsert();
	}
	
	/**
	 * 分类更新
	 * @return
	 */
	@RequestMapping("/cateUpdate")
	public String cateUpdate(HttpServletRequest request , String cid)
	{
		ConstatFinalUtil.LOGGER.info("---- cateUpdate ----");
		/* 按照Id查询 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", cid);
		/* 查询数据库 */
		AGoodsCate cate = this.goodsService.findOneGoodsCateService(condMap);
		/* 存储request */
		request.setAttribute("cate", cate);
		return "/back/goods/cateUpdate";
	}
	
	/**
	 * 分类更新提交
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/cateUpdateSubmit")
	public String cateUpdateSubmit(HttpServletRequest request,String cid ,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- cateUpdateSubmit ----");
		/* 按照Id查询 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", cid);
		/* 查询数据库 */
		AGoodsCate goodsCate = this.goodsService.findOneGoodsCateService(condMap);
		/* 存储request */
		request.setAttribute("goodsCate", goodsCate);
		
		String pubTimeStr = request.getParameter("pubTimeStr");
		goodsCate.setPubTime(this.dateFormatUtil.parse(pubTimeStr));
		
		String name = request.getParameter("name");
		String url = request.getParameter("url");
		String spec = request.getParameter("spec");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		
		goodsCate.setName(name);
		goodsCate.setUrl(url);
		goodsCate.setContent(content);
		goodsCate.setSpec(spec);
		goodsCate.setStatus(Byte.valueOf(status));
		
		goodsCate.setUpdateTime(new Date());
		
		JSONObject resDBJSON = this.goodsService.updateOneGoodsCateService(goodsCate);
		this.info = resDBJSON.getString("info");
		request.setAttribute("info", info);
		return this.cateUpdate(request,cid);
	}
	/*----------分类操作结束---------*/
	
	/*----------商品操作开始---------*/
	/**
	 * 商品列表
	 * 
	 * @return
	 */
	@RequestMapping("/goodsList")
	public String goodsList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- goodsList ----");
		/* 接收搜索条件 */
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		/* 处理搜索条件 */
		if(keyword == null)
		{
			keyword = ""; 
		}
		keyword = keyword.trim() ; 
		if(status == null)
		{
			status = ""; 
		}
		if(st == null)
		{
			st = ""; 
		}
		if(ed == null)
		{
			ed = ""; 
		}
		
		Date stDate = null ; 
		Date edDate = null ; 
		if(!"".equalsIgnoreCase(st) && !"".equalsIgnoreCase(ed))
		{
			stDate = this.dateFormatUtil.parse(st);
			edDate = this.dateFormatUtil.parse(ed);
		}
		
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		if(!"".equalsIgnoreCase(status))
		{
			condMap.put("status", status);
		}
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		/* 分页 */
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		List<AGoods> goodsList = this.goodsService.findCondListGoodsService(pageInfoUtil, condMap);
		
		/* 存储结果 */
		request.setAttribute("goodsList", goodsList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		request.setAttribute("websitePath", ConstatFinalUtil.BUNDLE.getString("website.path"));
		
		/* 存储条件 */
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		return "/back/goods/goodsList";
	}
	
	/**
	 * 商品添加
	 * @return
	 */
	@RequestMapping("/goodsInsert")
	public String goodsInsert(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- goodsInsert ----");
		/* 查询所有的品牌 */
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("status", AGoodsBrandEnum.STATUS_ENABLE.getStatus());
		List<AGoodsBrand> goodsBrandList = this.goodsService.findCondListGoodsBrandService(null, condMap);
		/* 查询所有的分类 */
		/*condMap.clear();
		condMap.put("status", AGoodsCateEnum.STATUS_ENABLE.getStatus());
		List<AGoodsCate> goodsCateList = this.goodsService.findCondListGoodsCateService(null, condMap);*/
		condMap.clear(); 
		condMap.put("parentId", "0");
		List<AGoodsCate> goodsCateList = this.goodsService.findCondListGoodsCateService(null, condMap);
		JSONArray goodsCateTreeArr = this.goodsService.findTreeGoodsCateService(goodsCateList,request.getContextPath());
		request.setAttribute("goodsCateTreeArr", goodsCateTreeArr);
		
		request.setAttribute("goodsBrandList", goodsBrandList);
		request.setAttribute("goodsCateList", goodsCateList);
		return "/back/goods/goodsInsert";
	}
	
	/**
	 * 商品添加提交
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/goodsInsertSubmit")
	public String goodsInsertSubmit(HttpServletRequest request,AGoods goods,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- goodsInsertSubmit ----");
		HttpSession session = request.getSession() ; 
		AAdmins admins = (AAdmins) session.getAttribute("admins");
		
		String pubTimeStr = request.getParameter("pubTimeStr");
		goods.setPubTime(this.dateFormatUtil.parse(pubTimeStr));
		
		/* 拼装规格 */
		JSONArray specArr = new JSONArray() ; 
		Map<String, String[]> paramsReqMap = request.getParameterMap() ;
		for (Iterator iterator = paramsReqMap.entrySet().iterator(); iterator.hasNext();)
		{
			Entry me = (Entry) iterator.next();
			String key = me.getKey() + "" ; 
			String[] value = (String[]) me.getValue() ; 
			if(key.startsWith("spec_name"))
			{
				/* 主体,处理器,内存
				 * spec_name_1
				 *  */
				JSONObject json = new JSONObject() ; 
				json.put("name", value[0]);
				
				String count = key.substring(key.lastIndexOf("_") + 1, key.length());
				json.put("count", count);
				specArr.add(json);
			}
		}
		
		/* 取出键
		 * [
				{
					"name": "主体",
					"keys": [
					{
						"name":"系列",
						"value":"T 系列"
					},
					{
						"name":"型号",
						"value":"ThinkPad T460"
					}]
				}
			]
		 *  */
		for (Iterator iterator = specArr.iterator(); iterator.hasNext();)
		{
			JSONObject json = (JSONObject) iterator.next();
			String count = json.getString("count");
			
			/* 取邮所有的键 */
			String[] keys = request.getParameterValues("spec_key_" + count);
			String[] values = request.getParameterValues("spec_value_" + count);
			
			JSONArray keysArr = new JSONArray();
			for (int i = 0; i < keys.length; i++)
			{
				String key = keys[i];
				JSONObject keysJSON = new JSONObject();
				keysJSON.put("name", key);
				keysJSON.put("value", values[i]);
				
				keysArr.add(keysJSON);
			}
			json.put("keys", keysArr);
		}
		
		goods.setSpec(specArr.toJSONString());
		goods.setAdminsId(admins.getId());
		goods.setCreateTime(new Date());
		goods.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		if(file != null)
		{
			paramsMap.put("oriFileName", file.getOriginalFilename());
			paramsMap.put("inputStream", file.getInputStream());
		}
		JSONObject resDBJSON = this.goodsService.saveOneGoodsService(goods,paramsMap);
		this.info = resDBJSON.getString("info");
		request.setAttribute("info", info);
		return this.goodsInsert(request);
	}
	/**
	 * 商品更新
	 * @return
	 */
	@RequestMapping("/goodsUpdate")
	public String goodsUpdate(HttpServletRequest request , String gid)
	{
		ConstatFinalUtil.LOGGER.info("---- goodsUpdate ----");
		/* 按照Id查询 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", gid);
		/* 查询数据库 */
		AGoods goods = this.goodsService.findOneGoodsService(condMap);
		/* 存储request */
		request.setAttribute("goods", goods);
		
		/* 查询所有的品牌 */
		condMap.clear();
		condMap.put("status", AGoodsBrandEnum.STATUS_ENABLE.getStatus());
		List<AGoodsBrand> goodsBrandList = this.goodsService.findCondListGoodsBrandService(null, condMap);
		/* 查询所有的分类 */
		/*condMap.clear();
		condMap.put("status", AGoodsCateEnum.STATUS_ENABLE.getStatus());
		List<AGoodsCate> goodsCateList = this.goodsService.findCondListGoodsCateService(null, condMap);*/
		condMap.clear(); 
		condMap.put("parentId", "0");
		List<AGoodsCate> goodsCateList = this.goodsService.findCondListGoodsCateService(null, condMap);
		JSONArray goodsCateTreeArr = this.goodsService.findTreeGoodsCateService(goodsCateList,request.getContextPath());
		request.setAttribute("goodsCateTreeArr", goodsCateTreeArr);
		
		request.setAttribute("goodsBrandList", goodsBrandList);
		request.setAttribute("goodsCateList", goodsCateList);
		request.setAttribute("websitePath", ConstatFinalUtil.BUNDLE.getString("website.path"));
		return "/back/goods/goodsUpdate";
	}
	
	/**
	 * 商品更新提交
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/goodsUpdateSubmit")
	public String goodsUpdateSubmit(HttpServletRequest request,String gid ,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- goodsUpdateSubmit ----");
		/* 按照Id查询 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", gid);
		/* 查询数据库 */
		AGoods goods = this.goodsService.findOneGoodsService(condMap);
		/* 存储request */
		request.setAttribute("goods", goods);
		
		String pubTimeStr = request.getParameter("pubTimeStr");
		goods.setPubTime(this.dateFormatUtil.parse(pubTimeStr));
		
		String cateId = request.getParameter("cateId");
		String brandId = request.getParameter("brandId");
		String name = request.getParameter("name");
		String title = request.getParameter("title");
		String url = request.getParameter("url");
		String weight = request.getParameter("weight");
		String remainNum = request.getParameter("remainNum");
		String marketPrice = request.getParameter("marketPrice");
		String price = request.getParameter("price");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		
		goods.setCateId(Integer.valueOf(cateId));
		goods.setBrandId(Integer.valueOf(brandId));
		goods.setName(name);
		goods.setTitle(title);
		goods.setUrl(url);
		goods.setWeight(Double.valueOf(weight));
		goods.setRemainNum(Integer.valueOf(remainNum));
		goods.setMarketPrice(Double.valueOf(marketPrice));
		goods.setPrice(Double.valueOf(price));
		goods.setContent(content);
		goods.setStatus(Byte.valueOf(status));
		
		/* 拼装规格 */
		JSONArray specArr = new JSONArray() ; 
		Map<String, String[]> paramsReqMap = request.getParameterMap() ;
		for (Iterator iterator = paramsReqMap.entrySet().iterator(); iterator.hasNext();)
		{
			Entry me = (Entry) iterator.next();
			String key = me.getKey() + "" ; 
			String[] value = (String[]) me.getValue() ; 
			if(key.startsWith("spec_name"))
			{
				/* 主体,处理器,内存
				 * spec_name_1
				 *  */
				JSONObject json = new JSONObject() ; 
				json.put("name", value[0]);
				
				String count = key.substring(key.lastIndexOf("_") + 1, key.length());
				json.put("count", count);
				specArr.add(json);
			}
		}
		
		/* 取出键
		 * [
				{
					"name": "主体",
					"keys": [
					{
						"name":"系列",
						"value":"T 系列"
					},
					{
						"name":"型号",
						"value":"ThinkPad T460"
					}]
				}
			]
		 *  */
		for (Iterator iterator = specArr.iterator(); iterator.hasNext();)
		{
			JSONObject json = (JSONObject) iterator.next();
			String count = json.getString("count");
			
			/* 取邮所有的键 */
			String[] keys = request.getParameterValues("spec_key_" + count);
			String[] values = request.getParameterValues("spec_value_" + count);
			
			JSONArray keysArr = new JSONArray();
			for (int i = 0; i < keys.length; i++)
			{
				String key = keys[i];
				JSONObject keysJSON = new JSONObject();
				keysJSON.put("name", key);
				keysJSON.put("value", values[i]);
				
				keysArr.add(keysJSON);
			}
			json.put("keys", keysArr);
		}
		
		if(specArr.size() > 0 )
		{
			goods.setSpec(specArr.toJSONString());
		}
		
		goods.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		if(file != null)
		{
			paramsMap.put("oriFileName", file.getOriginalFilename());
			paramsMap.put("inputStream", file.getInputStream());
		}
		JSONObject resDBJSON = this.goodsService.updateOneGoodsService(goods);
		this.info = resDBJSON.getString("info");
		request.setAttribute("info", info);
		return this.goodsUpdate(request,gid);
	}
	/*----------商品操作结束---------*/
}
